from MyTelloLib.MyTello import MyTello
from MyTelloLib.TelloCV import TelloCV


tello=MyTello('192.168.10.2')
telloCV=TelloCV(tello)
# telloCV.speed=30
# telloCV.speed2=20
telloCV.init_ball_tracker(lower=(12,80,150),upper=(30,255,255))

tello.takeoff()

while True:
    frame=tello.get_video_frame()
    if frame is not None:
        x,y,z,img=telloCV.ball_position(frame)
        telloCV.speed=50
        telloCV.speed2=30
        telloCV.xyz_control(x,y,z,15,50)
        if telloCV.show(img):
            break
        
        
tello.land().wait_for_completed()
tello.quit()
del telloCV
del tello